<script>
import axios from "axios";

export default {
  name: "fileUpload",
  data() {
    return {
      fileList:[]
    }
  },
  methods: {
    sendDataParent: function () {
      console.log("执行取消")
      console.log(this.$emit)
      this.$emit('closeDialog', false);
    },
    updateData() {
      axios.put("http://localhost:8088/departments", this.form).then(
          function (res) {
            console.log("请求成功")
            console.log(res.data)
          },
          function (error) {
            console.log("请求失败")
          }
      )
      this.$emit('closeDialog', false);
      this.$emit('refresh', true);
    },
    getPermissionIds() {
      console.log("拿到数据对象")
      console.log(this.$refs.tree.getCheckedKeys())
      console.log(this.rowData.id)
      let param = {
        id:this.rowData.id,
        permissionIds:this.$refs.tree.getCheckedKeys()
      }
      axios.post("http://localhost:8088/roles/addPermissionForRole", param).then(
          function (res) {
            console.log("请求成功")
            console.log(res.data)
          },
          function (error) {
            console.log("请求失败")
          }
      )
      this.$emit('closeDialog', false);
    },
  },
  props: ['dialogFormShow', 'rowData'],
  created() {
    console.log("修改页面初始化")
    console.log("选中列数据" + this.rowData)
  },
  mounted() {
    console.log("选中列数据" + this.rowData)
  },
  activated() {
    console.log("组件激活")
  },
  watch: {
    dialogFormShow: function (newValue, oldValue) {
      if (newValue === true) {
        let vue = this
        axios.get("http://localhost:8088/permissions/treeData").then(
            function (res) {
              console.log("请求成功")
              console.log(res.data)
              vue.dataTree = res.data.data
              console.log(vue.dataTree)
            },
            function (error) {
              console.log("请求失败")
            }
        )
      }
    }
  }
}
</script>

<!--
action	必选参数，上传的地址

on-preview	点击文件列表中已上传的文件时的钩子

on-remove	文件列表移除文件时的钩子

before-remove	删除文件之前的钩子，参数为上传的文件和文件列表，若返回 false 或者返回 Promise 且被 reject，则停止删除。

multiple	是否支持多选文件

limit	最大允许上传个数

on-exceed	文件超出个数限制时的钩子

file-list	上传的文件列表, 例如: [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}]

method:submit	手动上传文件列表
-->
<template>
  <el-container>
    <el-dialog title="导入线索" :visible.sync="dialogFormShow" @close="sendDataParent">
      <el-upload
          class="upload-demo"
          action="http://localhost:8088/uploads/uploadExcel"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :before-remove="beforeRemove"
          multiple
          :limit="3"
          :on-exceed="handleExceed"
          :file-list="fileList">
        <el-button size="small" type="primary">点击上传</el-button>
        <el-button @click="sendDataParent">确定</el-button>
        <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
      </el-upload>
    </el-dialog>
  </el-container>
</template>

<style scoped>

</style>
